#include "Tlc5940.h"
#include "LEDControl.h"
//#include "tlc_fades.h"

cLED LEDs[10];
cRGB Rot(255,0,0), Orange(235,110,30), Gelb(255,255,0), Gruen(0,255,0), Blau(0,0,255), Lila(102,84,149);
cRGB Regenbogen[6]={Rot, Orange, Gelb, Gruen, Blau, Lila};
cRGB buff;

void setup()
{
  int cnt=0;
  Tlc.init();
  for (int x=2;x<32;x+=3)
  {
    cLED LED(x+2,x,x+1);
    LEDs[cnt]=LED;
    cnt++;
  }
  Serial.begin(9600);
}

void loop()
{
    int change_r[6], change_g[6], change_b[6];
    for (int n=5; n>-1;n--)
    {
      if (n!=0)
        {
          change_r[n] = Regenbogen[n-1].red - Regenbogen[n].red;
          change_g[n] = Regenbogen[n-1].green - Regenbogen[n].green;
          change_b[n] = Regenbogen[n-1].blue - Regenbogen[n].blue;
        }
        else
        {
          change_r[n] = Regenbogen[5].red - Regenbogen[n].red;
          change_g[n] = Regenbogen[5].green - Regenbogen[n].green;
          change_b[n] = Regenbogen[5].blue - Regenbogen[n].blue;
        }
    }
    long st = 200;
    for (long x=1; x<st +1;x++)
    {
      for(int n=0; n<6;n++)
      {
        LEDs[n].setColor(Regenbogen[n].red + int(long(change_r[n] * x) / st),
                         Regenbogen[n].green + int(long(change_g[n] * x) /st),
                         Regenbogen[n].blue + int(long(change_b[n] * x) / st));
      }
      while(Tlc.update());
      delay(20);
    }
    
    /*for(int a=0;a<6;a++)
    {
     LEDs[a].setColor(Regenbogen[a]);

    }
         while(Tlc.update());
      delay(1000);*/
    
    delay(100);
    buff=Regenbogen[5];
    for(int i = 5;i>0;i--){
     
     Regenbogen[i]=Regenbogen[i-1];
    }
    Regenbogen[0]=buff;
}